package com.ly.loyi.common;

import java.util.List;


public class PageModel<T> {
	private List<T> list;
	private int pageNo;
	private int pageSize;
	private int allRecord;

	public PageModel() {
		super();
	}

	public PageModel(List<T> list, int pageNo, int pageSize, int allRecord) {
		super();
		this.list = list;
		this.pageNo = pageNo;
		this.pageSize = pageSize;
		this.allRecord = allRecord;
	}
	
	public int getAllRecords(){
		return (int) Math.ceil((double)allRecord/pageSize);
	}
	
	public int getFirst(){
		return 1;
	}
	public int getPre(){
		if (pageNo==1) {
			return 1;
		}
		return pageNo-1;
	}
	public int getNext(){
		if (pageNo==getAllRecords()) {
			return getAllRecords();
		}
		return pageNo+1;
	}
	public int getFinish(){
		return getAllRecords();
	}
	public List<T> getList() {
		return list;
	}

	public void setList(List<T> list) {
		this.list = list;
	}

	public int getPageNo() {
		return pageNo;
	}

	public void setPageNo(int pageNo) {
		this.pageNo = pageNo;
	}

	public int getPageSize() {
		return pageSize;
	}

	public void setPageSize(int pageSize) {
		this.pageSize = pageSize;
	}

	public int getAllRecord() {
		return allRecord;
	}

	public void setAllRecord(int allRecord) {
		this.allRecord = allRecord;
	}

}
